<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
	include '../../connection/connection.php';	
	include '../../value/value_kr.php';
	
$idcamera = $_REQUEST['idcamera'];
$name = $_REQUEST['name'];
$host = $_REQUEST['host'];
$postx = $_REQUEST['postx'];
$posty = $_REQUEST['posty'];
$dvr = $_REQUEST['dvr'];
$ip = $_REQUEST['ip'];
$port = $_REQUEST['port'];
$mode = $_REQUEST['mode'];
$userid = $_REQUEST['userid'];
$pw = $_REQUEST['pw'];


$insertsql = mysql_query("insert into configcamera(id,name,host,pos_x,pos_y,go_mode,DVR,IP,Port,UserID,PW)
 values('$idcamera','$name','$host','$postx','$$posty','$mode','$dvr','$ip','$port','$userid','$pw')");


	$list=$_SESSION['sort'];
	$str="cf.live_time";
	$_SESSION['sortn']=$str;
	$flagDesc=$_GET['flagDesc'];
	
	if($flagDesc==1){

		if($list[$str]=="DESC")
			$list[$str]="ASC";
		else
			$list[$str]="DESC";
	}
	$sql1 = "select cf.* from configcamera cf ";
$selectConfcamera = mysql_query($sql1." ORDER BY ".$str." ".$list[$str], $connection);
?>
<div style="overflow:scroll;overflow-x: hidden; width:100%; height:480px; background-color: #ffffff">
		     <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung"  id="tablebody2">
	     		<tbody>
					<?php 
                			$i = 0; 
			     		while ($row = mysql_fetch_array($selectConfcamera)){ 
			     			$i ++;?>
				     	<tr id="idrowconfcamera" onclick="onclickTableRow(this,<?=$row[id]?>);">
				     		<td style="text-align: center;width: 4%"><?=$i;?></td>
				     		<td style="text-align: center;width: 5%"><?=$row[id]?></td>
				     		<td style="width: 18%"><?php if ($row[name]==''){echo "&nbsp;";}else{?> <?=$row[name]?><?php }?></td>
				     		<td style="width: 6%"><?php if ($row[pos_x]==''){echo "&nbsp;";}else{?><?=$row[pos_x]?><?php }?></td>
				     		<td style="width: 6%"><?php if ($row[pos_y]==''){echo "&nbsp;";}else{?><?=$row[pos_y]?><?php }?></td>
				     		<td style="text-align: center;width: 6%"><?if ($row[go_mode]==1){echo $l_come;}else{echo $l_go;} ?></td>
				     		<td style="width: 20%"><?php if ($row[host]==''){echo "&nbsp;";}else{?><?=$row[host]?><?php }?></td>
				     		<td style="text-align: center;width: 4%"><?=$row[DVR]?></td>
				     		<td style="width: 10%"><?php if ($row[IP]==''){echo "&nbsp;";}else{?><?=$row[IP]?><?php }?></td>
				     		<td style="text-align: center;width: 6%"><?php if ($row[Port]==''){echo "&nbsp;";}else{?><?=$row[Port]?><?php }?></td>
				     		<td style="width: 9%"><?php if ($row[UserID]==''){echo "&nbsp;";}else{?><?=$row[UserID]?><?php }?></td>
				     		<td style="text-align: center;width: 6%" class="last"><?php if (strlen($row[PW])==0){echo "&nbsp;";}else{$vals="*"; for ($m=0;$m <strlen($row[PW]);$m++){?><?=$vals++;?><?php }}?></td>
				     	</tr>
			     	<?php 
			     			}?>
			     	
		     	</tbody>
		     </table>
		     </div>
		     	 <?php mysql_close($connection);?>